<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="dashboard/header :: header"></head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="operlog-form">
					<div class="select-list">
						<ul>
							<li>
								<label>链接名称  </label> <input type="text" name="condition[linkName|like]"/>
							</li>
							<li>
								<label>链接地址  </label> <input type="text" name="condition[linkPath|like]"/>
							</li>
							<li>
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="addModule()">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()">
		            <i class="far fa-trash-alt"></i> 删除
		        </a>
		        <a class="btn btn-danger" onclick="$.operate.clean()">
	                <i class="fa fa-trash"></i> 清空
	            </a>
	            <a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	
	<footer th:replace="dashboard/footer :: footer"></footer>

	<script>
		var detailFlag = "";
		var editFlag = "";
		var removeFlag = "";
		var resetPwdFlag = "";

		var prefix = ctx + "monitor/operlog";

		$(function() {
		    var options = {
		        url: ctx+ 'activiti/module/datatables' ,
		        createUrl: ctx + 'base/workflow/module/add' ,
		        updateUrl: ctx+"activiti/module/editor?id={id}" ,
		        statusUrl: ctx+"portal/desktop/web/linkPath/changeStatus?id={id}" , 
		        cleanUrl: prefix + "/clean",
		        detailUrl: ctx+"portal/desktop/web/linkPath/detail?id={id}",
		        removeUrl: ctx+"activiti/module/delete" ,
		        exportUrl: prefix + "/export",
		        sortName: "operTime",
		        uniqueId:"id" ,
		        sortOrder: "desc",
		        modalName: "操作日志",
		        escape: true,
		        showPageGo: true,
		        rememberSelected: true,
		        columns: [{field: 'state',checkbox: true },
		        	
			        {field: 'id', title: '模型主键'},
			        {field: 'key', title: '模型标识'},
			        {field: 'name', title: '模型名称'},
			        {field: 'version', title: '流程版本'},
			        
			        {field: 'createTime', title: '创建时间'},
			        {field: 'lastUpdateTime', title: '更新时间', sortable: true},
			        {field: 'id' , title: '操作',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                
			                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="moduleEditor(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="moduleDeploy(\'' + row.id + '\')"><i class="fa fa-leaf"></i>部署</a> ');
			                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="far fa-trash-alt"></i>删除</a> ');

			                return actions.join('');
			          }
			     }]
		    };
		    $.table.init(options);
		});
		
		function addModule(){
			top.layer.open({
			      type: 2,
			      title: '创建工作流模型',
			      shadeClose: true,
			      shade: false,
			      maxmin: false , //开启最大化最小化按钮
			      area: ['100%', '100%'],
			      btn: ['<i class="fa fa-check"></i> 确认', '<i class="far fa-trash-alt"></i> 关闭'],
			      content: ctx+'base/workflow/module/add'
			    });
		}
		
		function moduleEditor(_id){
			top.layer.open({
			      type: 2,
			      title: '创建工作流模型',
			      shadeClose: true,
			      shade: false,
			      maxmin: false , //开启最大化最小化按钮
			      area: ['100%', '100%'],
			      btn: ['<i class="fa fa-check"></i> 确认', '<i class="far fa-trash-alt"></i> 关闭'],
			      content: ctx+'activiti/module/editor?id='+_id 
			    });
		}
	
		// 部署流程图
		function moduleDeploy(_id){
			var url = ctx + "activiti/module/deploy" ; 
			var data = { "modelId": _id };
    	    $.operate.submit(url, "post", "json", data);	
		}
		
		function searchPre() {
		    var data = {};
		    data.businessTypes = $.common.join($('#businessTypes').selectpicker('val'));
		    $.table.search('operlog-form', data);
		}
		
		function resetPre() {
			$.form.reset();
			$("#businessTypes").selectpicker('refresh');
		}
		
	</script>
</body>
</html>